package com.bitsemart.VisorVideojuego;

import android.content.Context;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.widget.ImageView;

/**
 * Created by Roberto on 03/05/2015.
 *
 * ImageView especializado en mostrar imagenes con aspect ratio = 3:4
 */
public class ImageViewAspectRatio extends ImageView {
    public ImageViewAspectRatio (Context context) {
        super(context);
    }
    public ImageViewAspectRatio (Context context, AttributeSet attrs) {
        super (context,attrs);
    }
    public ImageViewAspectRatio (Context context, AttributeSet attrs, int defStyleAttr) {
        super (context,attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        //   let the default measuring occur, then force the desired aspect ratio
        //   on the view (not the drawable).
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        int width = getMeasuredWidth();
        //force a 4:3 aspect ratio
        int height = Math.round(width * .75f);
        setMeasuredDimension(width, height);
    }

}
